home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / Crossword / Source / CrosswordSquarePS.psw < prev    next >
Text File  |  1995-06-12  |  913b  |  41 lines

  1. /*
  2.  
  3. File CrosswordSquarePS.psw
  4.  
  5. This file contains the code to draw a crossword puzzle square.  The letter is centered within the square.  The number is put in the upper left hand corner at 1/4 the size of the letter.
  6.  
  7. */
  8.  
  9.  
  10. /* ————————————————————————————————————————————————————————————————————————————  */
  11.  
  12.  
  13. defineps PSWdrawSquare (int letter, number; float x, y, size, capheight)
  14.  
  15. x y translate
  16.  
  17.     %
  18.     % The font should already be set.  Center the letter horizontally on a
  19.     % baseline half the capheight from the center of the square.  Do not center it
  20.     % vertically in case it descends.
  21.     %
  22.  
  23.  
  24. letter -1 ne
  25. {
  26.     1 string dup dup 0 letter put                %    make the string
  27.     stringwidth pop neg size add 2 div            %    x
  28.     size capheight add 2 div                    %    y
  29.     moveto show
  30. } if
  31.  
  32.  
  33. number -1 ne
  34. {
  35.     currentfont 0.5 scalefont setfont            %    scale down the font
  36.     1 capheight 0.5 mul 1 add moveto            %    x & y
  37.     number 3 string cvs show
  38. } if
  39.  
  40.  
  41. endps